Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate OpenAPI spec during compile #1279

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open

Conversation

adamw
Copy link
Member

@adamw adamw commented Aug 6, 2024

No description provided.

@adamw adamw marked this pull request as draft August 6, 2024 15:29
@adamw
Copy link
Member Author

adamw commented Sep 5, 2024

More warnings, these seem to be connected to the client generation:

[0] WARNING in ./node_modules/openapi-client-axios/client.js
[0] Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
[0] Failed to parse source map from '/Users/adamw/projects/bootzooka/ui/node_modules/openapi-client-axios/src/client.ts' file: Error: ENOENT: no such file or directory, open '/Users/adamw/projects/bootzooka/ui/node_modules/openapi-client-axios/src/client.ts'
[0]
[0] WARNING in ./node_modules/openapi-client-axios/index.js
[0] Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
[0] Failed to parse source map from '/Users/adamw/projects/bootzooka/ui/node_modules/openapi-client-axios/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/adamw/projects/bootzooka/ui/node_modules/openapi-client-axios/src/index.ts'
[0]
[0] WARNING in ./node_modules/openapi-client-axios/types/client.js
[0] Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
[0] Failed to parse source map from '/Users/adamw/projects/bootzooka/ui/node_modules/openapi-client-axios/src/types/client.ts' file: Error: ENOENT: no such file or directory, open '/Users/adamw/projects/bootzooka/ui/node_modules/openapi-client-axios/src/types/client.ts'

@katekozlowska

@adamw
Copy link
Member Author

adamw commented Sep 5, 2024

But despite the warnings, the UI works :)

.then((client) => client.postUserLogin(null, { ...params, apiKeyValidHours: 1 }))
.then(({ data }) => apiKeySchema.validate(data));

export const register = (payload: RegisterParamsPayload) =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we generate these values as well? they seem to follow the same pattern, and that they can be fully computed from the API spec? this applies to the validation as well, doesn't it exactly follow what's in the OpenAPI schema?

@adamw adamw marked this pull request as ready for review September 23, 2024 10:34
@adamw
Copy link
Member Author

adamw commented Sep 23, 2024

@katekozlowska I think the minimal node version needs to be updated? It's 16 now, but when trying with node 16 I get:

error @oclif/[email protected]: The engine "node" is incompatible with this module. Expected version ">=18.0.0". Got "16.15.1"
error Found incompatible module.

Maybe let's update it to the current LTS simply?

@adamw
Copy link
Member Author

adamw commented Sep 23, 2024

Somewhat unrelated to the core task, but maybe https://softwaremill.github.io/bootzooka/stack.html would be good to extend with the main libraries used on the frontend - there are things like Formik or Yup (and possibly others) which I might guess as to why they are used, but it would be good to describe it too

@katekozlowska what about the docs? :)

.then((client) => client.postUserLogout(null, { apiKey }, secureRequest(apiKey)))
.then(({ data }) => emptySchema.validate(data).then(() => undefined));

export const getCurrentUser = (apiKey: string) =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katekozlowska it still seems that this code is "mechanical", that is, could be auto-generated. Same for the schemas. Is this something that we can do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants